import { useState } from 'react'
import './App.css'
import useLocalStorageState from './useLocalStorageState'

function App() {
  // localStorage中
  const STORAGE_NAME = 'app_theme'
  const ADDRESS_STORAGE_NAME = 'address'
  const defaultValue = {
    theme: "前端",
    address: "东华理工"
  }
  // const [value, setValue] = useState(() => {
  //   const storage = localStorage.getItem(STORAGE_NAME);
  //   return storage || '';
  // })
  const [value, setValue] = useLocalStorageState(STORAGE_NAME, defaultValue.theme);
  const [address, setAddress] = useLocalStorageState(ADDRESS_STORAGE_NAME, '')
  
  // console.log(useLocalStorageState(STORAGE_NAME, ''))
  // const changeValue = (value) => {
  //   setValue(value)
  //   // localStorage.setItem(STORAGE_NAME, value)
  // }
  return (
    <div className="App">
      <input value={value} onChange={e => setValue(e.target.value)} />
      <input value={address} onChange={e => setAddress(e.target.value)} />
    </div>
  )
}

export default App
